/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Ra
 */
package StudyBuddy;

import BackupClasses.ReadWrite;
import StudyBuddy.*;
import java.util.*;
import java.io.*;
public class TestDriver {
    
      public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LoginFrame().setVisible(true);
            }
        });
        
        String line = null;
        ReadWrite newReadWrite = new ReadWrite();
        Login newLogin = new Login();
        String name = null;
        String password = null;
        String file = "inTestfile.txt";

        
        newReadWrite.Write("**********Starting Registeration Testing ******line","RegTestResults.txt");
        
        BufferedReader inputStream = null;
     
        try
        {
            inputStream = new BufferedReader(new FileReader(file));
            line = inputStream.readLine();
            
            while(line != null)
            {
                
                StringTokenizer wordFinder = new StringTokenizer(line);
                name =  wordFinder.nextToken();
                password = wordFinder.nextToken();
                
                newLogin.getUsername(name);
                newLogin.getPassword(password);        
                newLogin.checkUsernamePassowrd();
                
                line = inputStream.readLine();
            }//while(line != null)
            
            inputStream.close();
        }
        catch(FileNotFoundException e)
        {
            System.out.println("File " + file + "was not found.");
        }
        catch(IOException e)
        {
            System.out.println("Error reading from file " + file +".");
        }
        
       
     
        newReadWrite.Write("**********Ending Registeration Testing ******line","RegTestResults.txt");
        newReadWrite.Write(" \n ","RegTestResults.txt");
        
        
        
        
       
        newReadWrite.Write("**********Stating Login Testing ******line","LoginTestResults.txt");
        try
        {
            
                inputStream = new BufferedReader(new FileReader(file));
                
            line = inputStream.readLine();
            while(line != null)
            {
                StringTokenizer wordFinder = new StringTokenizer(line);
                name =  wordFinder.nextToken();
                password = wordFinder.nextToken();
                
         
                newLogin.getUsername(name);
                System.out.println("Username " + name);
                newLogin.getPassword(password);
                    System.out.println("Username " + name);
                newLogin.validateUser();
            
                line = inputStream.readLine();
            }//while (line != null)
            
            inputStream.close();
        }
        catch(FileNotFoundException e)
        {
            System.out.println("File " + file + "was not found.");
        }
        catch(IOException e)
        {
            System.out.println("Error reading from file " + file +".");
        }
        
        
        
        
        newReadWrite.Write("**********Ending Login Testing ******line","LoginTestResults.txt");
    
         System.out.println("Test Completed");
        
        
    }

}
